#include<bits/stdc++.h>
using namespace std;
int main() {
  int n; cin>>n;
  int num, price;
  int ans = 0x3f3f3f3f;
  for(int i=0; i<3; ++i) {
    cin>>num>>price;
    ans = min(ans, ((n-1)/num+1)*price);
  }
  cout<<ans<<endl;
  return 0;
}
